<?php

// 发立得信息发布系统房屋信息版(php+mysql) V1.0
// 演示地址: http://fang.chalide.cn
// 文件路径: inc/head.php
// 文件大小: 2485 字节
// 最后修改时间: 2025-05-23 19:40:58
// 作者: yujianyue
// 邮件: 15058593138@qq.com
// 版权所有,保留发行权和署名权
/**
 * 本文件功能：公共头部
 * 版权声明：保留发行权和署名权
 * 作者信息：15058593138@qq.com
 */

// 开启会话
session_start();

// 引入必要文件
require_once './inc/conn.php';
require_once './inc/pubs.php';
require_once './sqls.php';

// 读取站点配置
$site = get_site_config();

// 当前用户
$curr_user = check_login();

// 当前菜单
$do = isset($_GET['do']) ? safe_input($_GET['do']) : '';
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $site['site_name']; ?></title>
    <meta name="description" content="<?php echo $site['site_desc']; ?>">
    <meta name="keywords" content="<?php echo $site['site_keywords']; ?>">
    <link rel="stylesheet" href="./inc/pubs.css?v=<?php echo $site['version']; ?>">
    <script src="./inc/js.js?v=<?php echo $site['version']; ?>"></script>
</head>
<body>
<div class="container">
    <div class="header">
        <div class="top-bar">
            <div class="title"><?php echo isset($page_title) ? $page_title : $site['site_name']; ?></div>
            <div class="right-btns">
                <?php if ($curr_user): ?>
                    <?php if ($curr_user['type'] == USER_TYPE_ADMIN): ?>
                        <a href="sys.php">管理后台</a>
                    <?php else: ?>
                        <a href="usr.php">用户中心</a>
                    <?php endif; ?>
                    <a href="<?php echo $curr_user['type'] == USER_TYPE_ADMIN ? 'sys.php?do=logout' : 'usr.php?do=logout'; ?>">退出</a>
                <?php else: ?>
                    <a href="usr.php?do=login">登录</a>
                <?php endif; ?>
            </div>
        </div>
        
        <?php if (isset($show_nav) && $show_nav): ?>
        <div class="nav">
            <a href="index.php">主页</a>
            <?php 
            $menu_arr = $curr_user['type'] == USER_TYPE_ADMIN ? $MENU_ADMIN : $MENU_USER;
            foreach ($menu_arr as $menu_item): 
            ?>
            <a href="<?php echo $curr_user['type'] == USER_TYPE_ADMIN ? 'sys.php?do=' : 'usr.php?do='; ?><?php echo $menu_item['do']; ?>" 
               class="<?php echo $do == $menu_item['do'] ? 'active' : ''; ?>">
                <?php echo $menu_item['name']; ?>
            </a>
            <?php endforeach; ?>
        </div>
        <?php endif; ?>
    </div>
    <div class="content">
